namespace Reflector.Languages
{
    using System;
    using System.Collections;
    using System.Runtime.InteropServices;

    internal class MethodNameExt
    {
        private bool var_Constructor;
        private bool var_Explicit;
        private bool var_ImplicitOrExplicit;
        private bool var_StaticConstructor;
        public string N;
        public ICollection O;
        public string OriginalN;

        public MethodNameExt(string Name, ICollection Overrides, string TypeName)
        {
            if (Name == "op_Explicit")
            {
                this.var_ImplicitOrExplicit = true;
                this.var_Explicit = true;
            }
            else if (Name == "op_Implicit")
            {
                this.var_ImplicitOrExplicit = true;
            }
            else if (Name == ".ctor")
            {
                Name = TypeName;
                this.var_Constructor = true;
            }
            else if (Name == ".cctor")
            {
                Name = TypeName;
                this.var_StaticConstructor = true;
            }
            this.OriginalN = Name;
            this.O = Overrides;
        }

        public bool Constructor
        {
            [return: MarshalAs(UnmanagedType.U1)]
            get
            {
                return this.var_Constructor;
            }
            [param: MarshalAs(UnmanagedType.U1)]
            set
            {
                this.var_Constructor = value;
            }
        }

        public bool Explicit
        {
            [return: MarshalAs(UnmanagedType.U1)]
            get
            {
                return this.var_Explicit;
            }
            [param: MarshalAs(UnmanagedType.U1)]
            set
            {
                this.var_Explicit = value;
            }
        }

        public bool ImplicitOrExplicit
        {
            [return: MarshalAs(UnmanagedType.U1)]
            get
            {
                return this.var_ImplicitOrExplicit;
            }
            [param: MarshalAs(UnmanagedType.U1)]
            set
            {
                this.var_ImplicitOrExplicit = value;
            }
        }

        public string Name
        {
            get
            {
                if (this.N == null)
                {
                    this.N = this.OriginalN;
                    if (!this.var_Constructor)
                    {
                        if ((this.O == null) || (this.O.Count > 0))
                        {
                            this.N = this.N.Replace(".", "_");
                        }
                        if (CppCliLanguage.LanguageWriter.specialMethodNames.Contains(this.N))
                        {
                            this.N = (string) CppCliLanguage.LanguageWriter.specialMethodNames[this.N];
                        }
                    }
                }
                return this.N;
            }
        }

        public bool StaticConstructor
        {
            [return: MarshalAs(UnmanagedType.U1)]
            get
            {
                return this.var_StaticConstructor;
            }
            [param: MarshalAs(UnmanagedType.U1)]
            set
            {
                this.var_StaticConstructor = value;
            }
        }
    }
}
